package com.solver.mapper;

import com.solver.entity.Field;
import com.solver.vo.QuestionItemVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface FieldMapper {

    /**
     * 根据分类id查询套餐的数量
     * @param id
     * @return
     */
    @Select("select count(id) from field where category_id = #{categoryId}")
    Integer countByCategoryId(Long id);

    /**
     * 动态条件查询
     * @param field
     * @return
     */
    List<Field> list(Field field);

    @Select("select fq.name, fq.copies, q.image, q.description " +
            "from field_question fq left join question q on fq.question_id=q.category_id " +
            "where fq.question_id = #{id}")
    List<QuestionItemVO> getQuestionItemById(Long id);

    @Select("select * from field  where id = #{fieldId}")
    Field getById(Long fieldId);
}
